<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>成品信息查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <link rel="stylesheet" href="../styles/base.css"/>
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../jqueryNicepage/css/layui.css"  media="all">
    <style>
        .body{
            background:#ddecf5;
            /*overflow-y: hidden;*/
        }
        .seachHeader {
            width:100%;
            height:auto;
            clear: both;
            padding-bottom: 10px;
        }
        .seachHeader span{
            margin-top: 5px;
            float: left;
            display: inline-block;
            height:30px;
            line-height: 30px;
            font-size: 16px;

        }
        .seachHeader span:first-child{
            margin-left: 20px;
        }
        .seachHeader .inputBox{
            float:left;
            width:200px;
            height:30px;
            line-height: 30px;
            font-size: 14px;
            padding-left: 10px;
            position: relative;
        }
        .seachHeader .inputBox input{
            width:190px;
            height:30px;
            line-height: 30px;
            position: absolute;
            padding-left: 10px;
            left:0;
        }
        .searchSureButton,.searchSureBtn{
            margin-left: 10px;
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #333;
            position: relative;
            padding: 1px 15px;
            /* margin-right: 15px;*/
            margin-top:2px;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
            overflow: hidden;
        }
        .searchSureButton:hover,.searchSureBtn:hover{
            color:#fff;
            background:#40E0D0;
        }
        .searchContainer{
            width:96%;
            max-height: 96%;
            min-height: 96%;
            margin-left: 2%;
            margin-top: 10px;
            min-width: 1300px;
        }
        .centerInput{
            margin-right: 10px;
        }
        .td0 a{
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
        }
        /*.layui-table tr .td0{
            cursor: pointer;
            color:#0000FF;
            text-decoration:underline ;
        }*/
        .addCuloumn{
            width:30px;
            height:100%;
            font-size: 20px;
            line-height: 30px;
        }
        .seachHeader ul{
            width:85%;
            height:auto;
        }
        .seachHeader ul .title{
            width:100px;
            text-align: left;
        }
        .seachHeader ul li .deleteItem{
            line-height: 35px;
        }
        .formContent{
            height:auto;
            /*overflow-y: scroll;*/
        }
        .formContent center{
            margin-top: -10px;
        }
        .selectedBox{
            width:90px;
            height:auto;
            position: absolute;
            border:1px solid #ccc;
            cursor: pointer;
            overflow: hidden;
            z-index: 9999999;
            background: #fff;
            display:none;
            padding: 10px 0;
        }
        .selectedBox p{
            width:100%;
            height:30px;
            line-height: 30px;
            font-size: 14px;
            border-bottom: 1px solid #ccc;
            padding-left: 10px;

        }
        .selectedBox p:last-child{
            border-bottom:0;
        }
        .selectedBox p:hover{
            background:#5FB878;
        }
        .formContent center #pageBar2{
            position:absolute;
            bottom:10px;
            width:100%;
            text-align: center;
            display:none;
        }
        .searchSureBtn{
            display:none;
            margin-top:10px;
            margin-right:30px;
        }
        .layui-laypage .layui-laypage-limits, .layui-laypage .layui-laypage-refresh {
            vertical-align: top;
            display: none;
        }
    </style>
</head>
<body class="body">
<div id="loading">
    <img src='../styles/img/loading.gif' />
</div>
<div class="searchContainer">
    <div class="seachHeader">
        <ul>

        </ul>
        <span class="rightEle"><div class="searchSureButton ">查询</div></span>
        <!--<span class="rightEle"><i title="增加一条输入条件" class="iconfont addCuloumn">&#xe601;</i>-->
            <div class="selectedBox">

            </div>
            </span>
        <div style="clear: both">

        </div>
    </div>
    <div class="formContent">
    </div>
    <div class="searchSureBtn">确定</div>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script src="../js/common/publicClass.js"></script>
<script src="../js/common/myAjax.js"></script>
<script src="../js/common/utils.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script>
    var height=document.body.clientHeight;
    var width =document.body.clientWidth;
    $("#loading img").css({
        "margin-left":width/2-25+"px",
        "margin-top":height/2-25+"px"
    })
    $("#loading").css({
        "display":"block"
    })
    var param=getQueryStringByNameTwo("param")!=undefined?getQueryStringByNameTwo("param"):"";
    MaterialReverseAjax("/Classification/getClassifictionIba","param="+param,callBackSelf)
  function callBackSelf(str) {
      $("#loading").css({
          "display":"none"
      })
      var searchInputArr=str.data!=undefined?str.data:[];
      if (searchInputArr.length > 0) {
             // var text = $(this).text();
              for (var i = 0; i < searchInputArr.length; i++) {
                 // if (text == searchInputArr[i].title) {
                      var oLi = "<li><span class='title'>" + searchInputArr[i] + "：</span><span data-v='" + searchInputArr[i] + "' class='centerInput centerInput"+i+"'></span><!--<span><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></span>--></li>";
                      $(".seachHeader ul").append(oLi);
                      $('.centerInput'+ i).append(setInput("请输入" + searchInputArr[i], "", 50, "text"));
                      focusOrBlur('.' + searchInputArr[i].className + '');
                 // }
              }
          /*})*/
      } else {
          //layerFn("暂无查询条件可以添加")
      }
  }
     /*   window.event? window.event.cancelBubble = true : e.stopPropagation();*/
$(".searchSureButton").click(function(){
    searchFn()
    function searchFn(){
        var obj={};
        for(var i=0;i<$("ul li").length;i++){
            if($("ul li").eq(i).find(".centerInput input").val()!=""){
                if($("ul li").eq(i).find(".centerInput").attr("data-v")=="panelPlaceOfOrigin"){
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]=$("ul li").eq(i).find(".centerInput input").val().replace(/\s+/g,"");
                }else{
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]= encodeURIComponent($("ul li").eq(i).find(".centerInput input").val().replace(/\s+/g,""));
                }

            }
        }
        if(JSON.stringify(obj)=="{}"){
            layerFn("查询条件不能全部为空");
            return;
        }
        for(var v in obj){
            if(obj[v]!=undefined&&obj[v]!=""){
                var url = "/FinishedGoodService/tmGetMaterialsApplication";
                // window.sqeExportExceldata=data;
                $("#loading").css({
                    display:"block"
                });
                MaterialReverseAjax1(url,obj,suCallback);
            }
        }

    }
    function suCallback(str){
        $(".formContent").empty();
        $("#loading").css({
            display:"none"
        });
        if(str!=undefined&&str.length>0){
            var dataListObjArr=[];
            for(var i=0;i<str.length;i++){
                var dataListObj={};
                dataListObj.finishedGoodModel =str[i].finishedGoodModel!=undefined?str[i].finishedGoodModel:"";
                dataListObj.name=str[i].name!=undefined?str[i].name:"";//成品名称
                dataListObj.number=str[i].number!=undefined?str[i].number:"";//成品编码
                dataListObj.finishedGoodSize=str[i].finishedGoodSize!=undefined?str[i].finishedGoodSize:"";//产品尺寸
                dataListObj.finishedGoodDisplayMode=str[i].finishedGoodDisplayMode!=undefined?str[i].finishedGoodDisplayMode:"";//显示模式
                dataListObjArr.push(dataListObj);
            }
            var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
            $(".formContent").css({
                "max-height":heightform*0.85,
                "overflow-y":"scroll"
            });
            window.selectedAll=true;
            window.historyList1 =dataListObjArr;
            window.headers1= ["<input id='checkAllData' title='全选' type='checkbox'>","序号","物料编码","物料描述","状态","分类","分类属性值"] //table的列名
            window.widths1 = ['100','100',"100","200","200","100","100"]//table每列的宽度
            $(".formContent").empty().load('./newTable.html',"",function(){
                setTimeout(function(){
                    var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;

                    if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                        $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
                    }else{
                        $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+50);
                    }
                    $("#pageBar2").css("display","block");
                    $(".searchSureBtn").css("display","block");

                    clearTimeout();
                    var marginlelftLen=[];
                    for(var i=0;i< $(".formContent table tbody tr").length;i++){
                        marginlelftLen.push($(".formContent table tbody tr").eq(i).find(".td0").text()*1)
                    }
                    for(var m=0;m<marginlelftLen.length;m++){
                        $(".formContent table tbody tr").eq(m).find(".td1  a").css({
                            "padding-left":marginlelftLen[m]*6
                        })
                    }
                },200)
            });
        }
    }
})
 /*   $("body").unbind().on("click",".formContent table tr td input",function(){
        $('input:radio').not(this).removeAttr('checked');

    })*/
   var arrFlage=[];
    $('body').unbind("click").on('click','tbody tr td input',function () {
        var father=$(this).parents("tr");
        var tdText=$(father).find(".td0").text();
      //  var tdEff=$(father).find(".td3 a").text();
     //   var versionText=encodeURIComponent(pubInputVal);
       // var texts=tdText+"&;"+tdEff+"&;"+versionText;
        var index=getIndexof(arrFlage,tdText);
        if(index<0){
            arrFlage.push(tdText);
        }else{
            arrFlage.splice(index, 1);
            $("#checkAllData").removeProp("checked","checked")
        }
        var flage=0;
        for(var i=0;i<$(".checkboxS").length;i++){
            if($(".checkboxS").eq(i).prop('checked')){
                //flage=true;
            }else{

                flage+=1;
            }
        }
        if(flage==0){
            $("#checkAllData").prop("checked","checked")
        }
    });
    $(".formContent").on("click","#checkAllData",function(){
        if($('#checkAllData').prop('checked')){//第一次点击
            $("tbody tr input").prop("checked","checked");
            for(var i=0;i<$("tbody tr ").length;i++){
                var tdText=$("tbody tr ").eq(i).find(".td0").text();
                var index=getIndexof(arrFlage,tdText);
                if(index==(-1)){
                    arrFlage.push(tdText);
                }
            }
        }else{//第二次点击
            $("tbody tr input").removeProp("checked");
            for(var i=0;i<$("tbody tr ").length;i++){
                var tdText=$("tbody tr ").eq(i).find(".td0").text();
                var index=getIndexof(arrFlage,tdText);
                if(index>(-1)){
                    arrFlage.splice(index, 1);
                }
            }
        }
    });
    window.onclick=function(){
        var flage=0;
        for(var i=0;i<$("tbody tr ").length;i++){
            var tdText=$("tbody tr ").eq(i).find(".td0").text();
            if(getIndexof(arrFlage,tdText)>(-1)){
                $(".checkboxS").eq(i).prop("checked","checked");
            }else{

            }
        }
        for(var m=0;m<$(".checkboxS").length;m++){
            if($(".checkboxS").eq(m).prop('checked')){
                flage+=1;
            }else{

            }
        }
        if(flage==$(".checkboxS").length){
            $("#checkAllData").prop("checked","checked")
        }
    }

    $(".searchSureBtn").click(function(){
        if(arrFlage.length>0){
            localStorage.setItem("AVLdata",arrFlage)
//console.log(localStorage.getItem("AVLdata"))
            window.close();
          //  window.open("MaterialClassificationTwo.html")
        }else{
            layerFn("请勾选数据");
        }
    })
</script>
</html>